import { cached } from '@/utils'
import request from '@/utils/request'

const BASE_URL = '/wms/base'

export function getMopAll() {
  return request({
    // url: BASE_URL + '/mop/material/list',
    url: '/wms/stock/stockMaterialList',
    method: 'get'
  })
}
export const getMopMaterials = cached(_ => getMopAll())
export function getAll() {
  return request({
    url: BASE_URL + '/material/list',
    method: 'get'
  })
}
export const getMaterials = cached(_ => getAll())
export function getInfo(query) {
  return request({
    url: BASE_URL + '/material/page',
    method: 'post',
    data: query
  })
}

export function getInfoBySupplierId(supplierId) {
  return request({
    url: BASE_URL + '/material/supplier/' + supplierId,
    method: 'GET'
  })
}

export function add(data) {
  return request({
    url: BASE_URL + '/material',
    method: 'post',
    data
  })
}

export function update(id, data) {
  return request({
    url: `${BASE_URL}/material/update`,
    method: 'put',
    data
  })
}

export function excelImport(file) {
  return request({
    url: BASE_URL + '/material/excelImport',
    method: 'post',
    data: file
  })
}

export function showQR(id) {
  return request({
    url: `${BASE_URL}/material/qrCode/${id}`,
    method: 'get',
    responseType: 'blob'
  })
}

export function getAllMopMaterial() {
  return request({
    url: BASE_URL + '/mop/material/list',
    method: 'get'
  })
}

